footer.html<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" />
		<link rel="stylesheet" href="css/Site.css" />
		<link rel="stylesheet" href="css/zy.all.css" />
		<link rel="stylesheet" href="css/font-awesome.min.css" />
		<link rel="stylesheet" href="css/amazeui.min.css" />
	  <link rel="stylesheet" href="css/admin.css" />
	</head>

	<body>
		<div class="dvcontent">

			<div>
				<!--tab start-->
				<div class="tabs">
					<div class="hd">
						<ul>
							<li class="on" style="box-sizing: initial;-webkit-box-sizing: initial;">修改商品</li>
						</ul>
					</div>
					
	<div class="am-cf admin-main" style="padding-top: 0px;display: block;">
		<!-- content start -->
		<div class="admin-content">
			<div class="admin-content-body">
				
				<div class="am-g">
					<div class="am-u-sm-12 am-u-md-4 am-u-md-push-8">
						
					</div>
					<div class="am-u-sm-12 am-u-md-8 am-u-md-pull-4"
						style="padding-top: 30px;">
						<form class="am-form am-form-horizontal" action="#" method="post" id="form_update">
						
							<div class="am-form-group">
								<label for="name" class="am-u-sm-3 am-form-label">
									商品名称</label>
								<div class="am-u-sm-9">
									<input type="hidden" name="pid" th:value="${product.pid}"/>
									<input type="text" id="name" required
										placeholder="商品名称" name="pname" th:value="${product.pname}">
										<small>10字以内...</small>
								</div>
							</div>
							
							<div class="am-form-group">
								<label for="name" class="am-u-sm-3 am-form-label">
									商品数量</label>
								<div class="am-u-sm-9">
									<input type="text" id="name" required
										placeholder="商品数量" name="pnumber" th:value="${product.pnumber}">
										<small>...</small>
								</div>
							</div>
							
							<div class="am-form-group">
								<label for="user-email" class="am-u-sm-3 am-form-label">
								分类</label>
								<div class="am-u-sm-9">
									<select name="type.tid" required id="select_product_type">
										<option value="-1">请选择分类</option>
									</select>
								</div>
							</div>
							<div class="am-form-group">
								<label for="user-intro" class="am-u-sm-3 am-form-label">
									备注</label>
								<div class="am-u-sm-9">
									<textarea class="" rows="5" id="user-intro" name="premark" th:text="${product.premark}"
										placeholder="输入备注"></textarea>
									<small>250字以内...</small>
								</div>
							</div>
							<div class="am-form-group">
								<div class="am-u-sm-9 am-u-sm-push-3">
									<input type="button" onclick="update_product();" class="am-btn am-btn-success" value="修改商品" />
								    <input type="button" class="am-btn am-btn-success" value="返回列表" />
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		
		</div>
		<!-- content end -->
	</div>
							<!--添加 end-->
						</ul>
					</div>
				</div>
				<!--tab end-->

			</div>

			
			 <script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
              <script src="js/plugs/Jqueryplugs.js" type="text/javascript"></script>
              <script src="js/_layout.js"></script>
             <script src="js/plugs/jquery.SuperSlide.source.js"></script>
			<script>
				var num = 1;
				$(function() {

				 $(".tabs").slide({ trigger: "click" });

				});

	
				var btn_save = function() {
					var pid = $("#RawMaterialsTypePageId  option:selected").val();
					var name = $("#RawMaterialsTypeName").val();
					var desc = $("#RawMaterialsTypeDescription").val();
					var ramark = $("#Ramark").val();
					$.ajax({
						type: "post",
						url: "/RawMaterialsType/AddRawMaterialsType",
						data: { name: name, pid: pid, desc: desc, ramark: ramark },
						success: function(data) {
							if(data > 0) {
								$.jq_Alert({
									message: "添加成功",
									btnOktext: "确认",
									dialogModal: true,
									btnOkClick: function() {
										//$("#RawMaterialsTypeName").val("");
										//$("#RawMaterialsTypeDescription").val("");
										//$("#Ramark").val("");                           
										//page1();
										location.reload();

									}
								});
							}
						}
					});
					alert(t);
				}

				var btn_edit = function(id) {
					$.jq_Panel({
						url: "/RawMaterialsType/EditRawMaterialsType?id=" + id,
						title: "编辑分类",
						dialogModal: true,
						iframeWidth: 500,
						iframeHeight: 400
					});
				}
				var btn_delete = function(id) {
					$.jq_Confirm({
						message: "您确定要删除吗?",
						btnOkClick: function() {
							
						}
					});
				}

				//页面加载绑定下拉框
				$(function () {
					$.ajax({
						url:"/product_types",
						type:"post",
						dataType:"json",
						success:function (result) {
							//alert(JSON.stringify(result));
							for(var i=0;i<result.length;i++){
								//if(result[i].tid==[[${product.type.tid}]]){
									//$("#select_product_type").append("<option selected value='"+result[i].tid+"'>"+result[i].tname+"</option>");
								//}else{
									$("#select_product_type").append("<option value='"+result[i].tid+"'>"+result[i].tname+"</option>");
								//}
							}
							//下拉框选中,直接让下拉框的value值等于要回显的值
							$("#select_product_type").val([[${product.type.tid}]]);
						}
					});
				});

				//异步更新
				function update_product() {
					var formdata=$("#form_update").serialize();
					//缺不缺点东西??
					//alert(formdata);
					$.ajax({
						url:"/product_update",
						type:"post",
						data:formdata,
						dataType:"json",
						success:function (result) {
							//alert(JSON.stringify(result));
							if(result.code==200){
								alert("更新成功!");
								location.href="/product_list";
							}else{
								alert("更新失败,你看看BUG!!!!!");
							}
						}
					});
				}

			</script>

		</div>
	</body>

</html>